package com.study.spring_redis.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @Author yangjin
 * @Description
 * @Date 2021/8/16/23:33
 **/
@Component
public class SpringUtils implements ApplicationContextAware {

    private static ApplicationContext context;

    public static String getConfig(String key) {
        return context.getEnvironment().getProperty(key);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        SpringUtils.context = applicationContext;
    }
}
